package com.duan.laugh.sms.listener;

import com.duan.laugh.msg.api.pojo.entity.MsgSend;
import com.duan.laugh.sms.api.constans.SmsConstants;
import com.duan.laugh.sms.service.ISmsSendService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 队列消息监听
 *
 * @author duanjw
 */
@Component
@Slf4j
@AllArgsConstructor
public class SmsReceiveListener {

    private final ISmsSendService smsSendService;

    /**
     * 监听sms队列消息
     *
     * @param msgSend
     */
    @RabbitListener(queues = SmsConstants.MQ_QUEUE_SMS)
    public void receive(MsgSend msgSend) {
        log.info("监听到短信发送请求：{}", msgSend);
        smsSendService.sendSms(msgSend);
        log.info("给指定用户推送短信消息完毕");
    }
}
